package aexp.customview;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewInflate;
import android.widget.TextView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import java.util.List;

public class AlarmAdapter extends BaseAdapter {

    private Context context;
    private List<Alarm> alarmList;
	private int rowResID;

    public AlarmAdapter(Context context, int rowResID,
						List<Alarm> alarmList ) { 
        this.context = context;
		this.rowResID = rowResID;
        this.alarmList = alarmList;
    }

    public int getCount() {                        
        return alarmList.size();
    }

    public Object getItem(int position) {     
        return alarmList.get(position);
    }

    public long getItemId(int position) {  
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) { 
        Alarm alarm = alarmList.get(position);
		ViewInflate inflate = ViewInflate.from( context );
		View v = inflate.inflate( rowResID, parent, false, null);
		TextView alarmTextControl = (TextView)v.findViewById( R.id.alarmtext );
		if( alarmTextControl != null )
			alarmTextControl.setText( alarm.getAlarmText() );
	    AlarmingView alarmingControl = (AlarmingView)v.findViewById( R.id.alarming );
		if( alarmingControl != null )
	    	alarmingControl.setAlarming( alarm.getAlarming() );
        return v;
    }

}
